var areaJson = {1:"华东",2:"华南",3:"华北",4:"政企"};
var statusJson = {1:"已删除",0:"正常"};
$(function() {
	initTable();
	doSearch();
});

function initTable(){
	$('#dataDrig').myTable({
		width : getWidth(0.98),
		rownumber : false,
		pagination : true,
		checkbox : false,
		paginationTop : true,
		url : '',
		pageNumberName:'pageNumber',
		pageSizeName:'pageSize',
		queryParams:{},
		pageList:[2,10,20,30],
		columns: [
					{field : 'picOldName',title : '图片',width : $(this).width() * 0.06,align : 'center',
						formatter : function(value, rec, index) {
							var html = '<a target="_blank" href="'+$("#baseUrl").val()+'/static/upload/'+rec.picNewName+'" title="'+value+'">';
							if(value.length>100){
								html += value.substr(0,100)+"...";
							}else {
								html += value;
							}
							return html+'</a>';
						}
					},
					{field : 'activityTopic',title : '活动名称',width : $(this).width() * 0.03,align : 'center',
						formatter : function(value, rec, index) {
							if(value || value == 0){
								return value;
							}else {
								return "";
							}
						}
					},
					{field : 'companyUserName',title : '客户',width : $(this).width() * 0.02,align : 'center',
						formatter : function(value, rec, index) {
							if(value || value == 0){
								return value;
							}else {
								return "";
							}
						}
					},
					{field : 'ctimeStr',title : '创建时间',width : $(this).width() * 0.02,align : 'center'}
				]
	});
}

//查询
function doSearch(){
	formJson=$("#searchForm").form2json();
	url='../pics/findPage';
	var opts = $('#dataDrig').myTable('options');
	opts.pageNumber = 1;
	var queryParams ={};
	queryParams = $.extend(queryParams,formJson);
	opts.queryParams = queryParams;
	opts.url=url;
	$('#dataDrig').myTable('options').url = url,
	$('#dataDrig').myTable('reload');
}

function doReset(){
	document.getElementById("searchForm").reset();
}